"// ..." comments at end of code block after } - good or bad?
        Posted  
        
            by 
                gablin
            
        on Programmers
        
        See other posts from Programmers
        
            or by gablin
        
        
        
        Published on 2011-03-01T11:35:00Z
        Indexed on 
            2011/03/01
            15:32 UTC
        
        
        Read the original article
        Hit count: 299
        
I've often seen such comments be used:
function foo() {
   ...
} // foo
while (...) {
   ...
} // while
if (...) {
   ...
} // if
and sometimes even as far as
if (condition) {
   ...
} // if (condition)
I've never understood this practice and thus never applied it. If your code is so long that you need to know what this ending } is then perhaps you should consider splitting it up into separate functions. Also, most developers tools are able to jump to the matching bracket. And finally the last is, for me, a clear violation to the DRY principle; if you change the condition you would have to remember to change the comment as well (or else it could get messy for the maintainer, or even for you).
So why do people use this? Should we use it, or is it bad practice?
© Programmers or respective owner